{extend name="public/base" /} {block name="title"}
<title>栏目管理</title>
{__block__}
<link href="//cdn.bootcss.com/datatables/1.10.15/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/iCheck/1.0.2/skins/all.css" rel="stylesheet">
<style>
    .editCategory :hover,
    .delCategory :hover {
        color: #000;
    }
</style>
<script>
    var indexCategoryUrl = "{:url('admin/category/index')}"
    var addCategoryUrl = "{:url('admin/category/add')}"
    var editCategoryUrl = "{:url('admin/category/edit')}"
    var changeStatusUrl = "{:url('admin/category/status')}"
    var delCategoryUrl = "{:url('admin/category/del')}"
</script>
{/block} {block name="page-heading"}
<div class="col-sm-4">
    <h2>栏目管理</h2>
    <ol class="breadcrumb">
        <li>
            <a href="{:url('admin/Index/home')}">主页</a>
        </li>
        <li>
            <strong>栏目管理</strong>
        </li>
    </ol>
</div>
<div class="col-sm-8">
    <div class="title-action">
        <a data-toggle="modal" class="btn btn-primary" href="#addCategoryModal">添加栏目</a>
        <a href="{:url('admin/article/index')}" class="btn btn-primary">文章管理</a>
        <a href="{:url('admin/tag/index')}" class="btn btn-primary">标签管理</a>
    </div>
</div> {/block} {block name="content"}
<table class="table categoryTable table-striped table-hover table-condensed">
    <thead>
        <tr>
            <th></th>
            <th>栏目名</th>
            <th>标识</th>
            <th>文章数</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        {foreach name="data" item="category"}
        <tr>
            <td>
                <input type="checkbox" value="{$category.id}" name="cid">
            </td>
            <td>{$category.name}</td>
            <td>{$category.flag}</td>
            <td>{$category.id|getCountByCategory}</td>
            <td>
                <a href="javascript:void(0)" onclick="changeCategoryStatus('{$category.id}','{$category.status}')">
                        {eq name="category.status" value='1'}隐藏
                            {else/}显示{/eq}
                    </a>&nbsp;&nbsp;
                <a class="text-success editCategory">
                                        <i class="fa fa-pencil-square-o" ></i>
                                    </a>&nbsp;&nbsp;
                <a class="text-danger delCategory">
                                        <i class="fa fa-trash"></i>
                                    </a>
            </td>
        </tr>
        {/foreach}
    </tbody>
    <tfoot>
        <tr>
            <th></th>
            <th>栏目名</th>
            <th>标识</th>
            <th>文章数</th>
            <th>操作</th>
        </tr>
    </tfoot>
</table>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectAll('cid')">全选</a>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectEmpty('cid')">全不选</a>
<a href="javascript:void(0)" class="btn btn-primary" onclick="selectReverse('cid')">反选</a>
<a href="javascript:void(0)" class="btn btn-danger" id="delSelectedCategory">删除选定</a> {/block} {block name="extra"}
<!--添加栏目  -->
<div class="modal fade" id="addCategoryModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="form-horizontal" role="form" id="addCategoryForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">添加栏目</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目名称</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" class="form-control" placeholder="请输入栏目名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目标识</label>
                        <div class="col-sm-10">
                            <input type="text" name="flag" class="form-control" placeholder="请输入栏目标识">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">关键词</label>
                        <div class="col-sm-10">
                            <input type="text" name="keywords" class="form-control" placeholder="请输入关键词，以顿号隔开">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10">
                            <input type="text" name="description" class="form-control" placeholder="请输入描述，未输入自动获取">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否显示</label>
                        <div class="col-sm-10">
                            <label class="radio-inline i-checks"><input type="radio" value="1" id="status1" name="status" >&nbsp;&nbsp;是</label>
                            <label class="radio-inline i-checks"><input type="radio" value="0" id="status0" name="status" >&nbsp;&nbsp;否</label>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<!--编辑栏目  -->
<div class="modal fade" id="editCategoryModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="form-horizontal" role="form" id="editCategoryForm">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title">编辑栏目</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目名称</label>
                        <div class="col-sm-10">
                            <input type="text" name="name" id="editName" class="form-control" placeholder="请输入栏目名称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目标识</label>
                        <div class="col-sm-10">
                            <input type="text" name="flag" id="editFlag" class="form-control" placeholder="请输入栏目标识">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">关键词</label>
                        <div class="col-sm-10">
                            <input type="text" name="keywords" id="editKeywords" class="form-control" placeholder="请输入关键词">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">描述</label>
                        <div class="col-sm-10">
                            <input type="text" name="description" id="editDescription" class="form-control" placeholder="请输入描述">
                        </div>
                    </div>
                    <input type="hidden" name="id" id="editId">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div> {/block}{block name="script"}{__block__}
<script src="//cdn.bootcss.com/datatables/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="//cdn.bootcss.com/datatables/1.10.15/js/dataTables.bootstrap.min.js"></script>
<script src="//cdn.bootcss.com/limonte-sweetalert2/6.6.8/sweetalert2.min.js"></script>
<script src="//cdn.bootcss.com/iCheck/1.0.2/icheck.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="//cdn.bootcss.com/jquery-validate/1.17.0/localization/messages_zh.min.js"></script>
<script src="__CUSTOME__/js/admin.validate.js"></script>
<script src="__CUSTOME__/js/admin.common.js"></script>
<script>
    $(function () {
        $(".categoryTable").dataTable({
            language: {
                url: "__PLUGINS__/dataTables/Chinese.json"
            },
            "columns": [{
                "orderable": false
            }, null, null, null, {
                "orderable": false
            }, ],
        });
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        });
    });
</script> {/block}